 import apiType, {
    GET_EMPLOYEE_LIST,
    GET_EMPLOYEE_INVITE_TOKEN,
    GET_ROLE_LIST,
    GET_PERMISSION_LIST,
    GET_SUPER_ADMIN
} from "@constants/ActionTypes";
import {setCookie} from "@utils/cookie";

const initialState = {
    employeeListMap: {}, // 员工列表
    employeeInviteToken: null,
    employeeRoleList:{}, // 角色列表
    permissionList:[], // 权限列表
    superAdmin:{}, // 超级管理员信息
}

export default function update(state = initialState, action) {
    const { response, params, payload } = action
    switch (action.type) {

        case apiType(GET_EMPLOYEE_LIST).success:
            return {
                ...state,
                employeeListMap: response,
            }
        case apiType(GET_EMPLOYEE_INVITE_TOKEN).success:
            return {
                ...state,
                employeeInviteToken: response.share_token,
            }
        case apiType(GET_ROLE_LIST).success:
            return {
                ...state,
                employeeRoleList: response,
            }
        case apiType(GET_PERMISSION_LIST).success:
            return {
                ...state,
                permissionList: response.permissions,
            }
        case apiType(GET_SUPER_ADMIN).success:
            return {
                ...state,
                superAdmin: response,
            }
        default:
            return state
    }
}